package Z.dailyExercise._0223;

public class _剑指Offer28对称的二叉树 {
    //问题转换 ==判断左右两个子数相等
    //只能用递归了 纯迭代 不好进行判断
    public boolean isSymmetric(TreeNode root) {
        if (root == null) return true;

        return helper(root.left,root.right);
    }

    boolean helper(TreeNode l,TreeNode r){
        if (l == null && r == null){
            return true;
        }

        if (l == null || r == null || l.val != r.val){
            return false;
        }

        return helper(l.left,r.right) && helper(l.right,r.left);

    }
}
